﻿@imports Library

@modelType MonthlySummary

@Code
    ViewData("Title") = "Edit"
End Code

<div id="page">

    <div id="page_header" style="position:relative;">
        Edit Record
    </div>

    <div id="page_body">
            
        <div class="IE_padding_hack">
	
            @Using Html.BeginForm("Edit", "MonthlySummary", New With {.id = Model.Id}, FormMethod.Post)
                    
                @<table class="basic">
                    <tr>
                        <th><label for="month"> Month  <b class="red">*</b></label></th>
                        <td>@Html.EditorFor(Function(model) model.Month)
                                <span> YYYY-MM format.Required. </span></td>
                    </tr><tr>
                        <th><label for="owner"> Owner <b class="red">*</b></label></th>
                        <td>@Html.EditorFor(Function(model) model.Owner)</td>
                    </tr><tr>
                        <th><label for="spend"> Spend <b class="red">*</b></label></th>
                        <td>@Html.EditorFor(Function(model) model.Spend)</td>
                    </tr><tr>
                        <th><label for="income"> Income <b class="red">*</b></label></th>
                        <td>@Html.EditorFor(Function(model) model.Income)</td>
                    </tr><tr>
                        <th><label for="remark"> Remark <b class="red">*</b></label></th>
                        <td>@Html.EditorFor(Function(model) model.Remark)</td>
                    </tr><tr>
                        <td colspan="2">
                            <input type="submit" id="submit" value="Save"> or 
                            <a href="javascript:void(0)" onclick="DeleteRecord()">Delete</a> or 
                            @Html.ActionLink("Cancel", "Index")
                        </td>
                    </tr>
                </table>

            End Using

        </div>
                    
    </div>
        
</div>

@section Scripts

<script type="text/javascript">

    $(function () {
        $("#banner li").removeClass("active").eq(3).addClass("active");

        $("#submit").click(function () {
            var spend = $("#Spend").val();
            var income = $("#Income").val();
            if (IsNumeric(spend) && IsNumeric(income)) {
                $("#Spend").val(Math.round(spend));
                $("#Income").val(Math.round(income));
                return true;
            } else {
                alert("amount is not a number!");
                return false;
            };
        });
    });

    function DeleteRecord() {
        if (confirm("Are you sure to delete this record?")) {
            window.location.href = '/MonthlySummary/delete?id=@Model.Id';
        }
    }
    
</script>

End Section
